<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AdminUserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|min:4|max:10',
            'password' => 'required|min:6|max:12|confirmed',
            'password_confirmation' => 'required|min:6|max:12',
            'phone' => 'required|max:11',
            'email' => 'required|email',
            'role' => 'required'
        ];
    }

    public function messages()
    {
        return [
            'name.required' => '管理员名不能为空',
            'name.min' => '管理员名字最小为4位，最大为10位',
            'name.max' => '管理员名字最小为4位，最大为10位',
            'password.required' => '密码不能为空',
            'password.min' => '密码最小为6位，最大为12位',
            'password.max' => '密码最小为6位，最大为12位',
            'password.confirmed' => '两次密码填写不一致',
            'phone.required' => '手机号不能为空',
            //'phone.numeric' => '手机号格式不正确',
            'phone.max' => '手机号格式不正确',
            'email.required' => '邮箱不能为空',
            'email.email' => '邮箱格式不正确',
            'role' => '角色不能为空'

        ];
    }
}
